package vip.ola.core.service.code;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import vip.ola.core.common.vo.UserDayProfitVO;
import vip.ola.core.entity.PayOrder;
import vip.ola.core.entity.code.CodeOrder;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;


/**
 * <p>
 * 二维码订单信息 服务类
 * </p>
 *
 * @author faker
 * @since 2020-03-25
 */
public interface CodeOrderService extends IService<CodeOrder> {

    IPage<CodeOrder> list(int offset, int limit, CodeOrder order);

    CodeOrder getByCodeOrder(CodeOrder codeOrder);

    CodeOrder getByOrderNo(String orderNo);

    void confirm(CodeOrder codeOrder);

    void updateAmount(long id, BigDecimal updateAmount);

    JSONObject distributeCodeOrder(PayOrder payOrder, Long codeBusId, int codeType, boolean needThirdId);

    boolean updateOperatePhase(String orderNo, Integer operatePhase, String clientIp, String device);

    boolean updateStatus4Complete(String orderNo);

    List<CodeOrder> getRiskOrderList(Long codeBusId);

    /**
     * 统计所有订单
     *
     * @param param
     * @return
     */
    Map countAll(CodeOrder order);

    /**
     * 统计成功订单
     *
     * @param param
     * @return
     */
    Map countSuccess(CodeOrder order);

    /**
     * 统计未付订单
     *
     * @param param
     * @return
     */
    Map countFail(CodeOrder order);

    Map<Long, UserDayProfitVO> countSuccessByUser(Long codeBusId, LocalDate date);

    /**
     * 处理失效的订单
     *
     * @param startTime
     * @param endTime
     * @return
     */
    List<CodeOrder> handleExpireOrder(LocalDateTime startTime, LocalDateTime endTime);
}
